#include "basic_tim.h"


void BASIC_TIM_NVIC_Config()
{
	NVIC_InitTypeDef NVIC_InitStructure;
	
	NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4);
	
	NVIC_InitStructure.NVIC_IRQChannel = TIM6_DAC_IRQn;
	NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
	NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 6;
	NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
	
	NVIC_Init(&NVIC_InitStructure);

}

void BASIC_TIM_Config(void)
{
	TIM_TimeBaseInitTypeDef TIM_InitStructure;
	
	 RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM6, ENABLE);
	
	
	TIM_InitStructure.TIM_ClockDivision = 8400-1;
	TIM_InitStructure.TIM_Period = 5000-1;
	
	
	TIM_TimeBaseInit(TIM6,&TIM_InitStructure);
	
	BASIC_TIM_NVIC_Config();
	
	TIM_ITConfig(TIM6, TIM_IT_Update, ENABLE);
	
	TIM_Cmd(TIM6,ENABLE);
	
}